package com.bosssoft.ct.springcloud.controller;

import com.bosssoft.ct.springcloud.service.HystrixTestService;
import com.bosssoft.ct.springcloud.utils.http.HttpResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 提供超时或者可能造成系统错误的接口来测试服务降级以及服务熔断
 *
 * @author ChenTong
 * @version 1.0
 * @date 2020/6/22 21:23
 * @copyright
 * @modified
 * @see
 * @since
 **/
@RestController
@Slf4j
@RequestMapping("/test")
public class HystrixTestController {
    @Resource
    HystrixTestService hystrixTestService;

    @GetMapping("/ok")
    public HttpResult ok(){
        return HttpResult.ok(hystrixTestService.adminOK());
    }

    @GetMapping("/timeout")
    public HttpResult testTimeout(){
        return HttpResult.ok(hystrixTestService.adminTimeout());
    }

    @GetMapping("/error")
    public HttpResult error(){
        return HttpResult.ok(hystrixTestService.adminError());
    }
}
